<!-- 评论组件 -->
<template>
  <div class="tmpl">

  </div>
</template>

<script type="text/javascript">
export default{
  methods: {
    data(){
      return {
        comments: []
      }
    },
    methods:{
      sendMessage(){
        //1.获取提交内容
        var txt = this.$refs.commentContent.value;
        //2.发出ajax的post请求
        var url = common.apiDomain + '/api/postcomment/' + this.artid;
        this.$http.post(url,{content:txt},{emulateJSON: true})
        .then(res=>{
          Toast(res.body.message);
          this.$refs.commentContent.value = ''
        });
        //3.刷新当前artid对应的评论列表数据

      },
      sendMessage: function(){
        var txt = this.$refs.commentContent.value;
        var url = common.apiDomain = '/api/postcomment/' + this.artid;
        this.$http.post(url,{content: txt},{emulateJSON: true})
        .then(res => {
          Toast(res.body.message);
          this.$refs.commentContent.value = '';
        })
      },
      getMessage: function(){
        var url = common.apiDomain + '/api/getcomments/' + this.artid + '?pageindex=1';
        this.$http.get(url).then(res => {
          if(res.body.status !== 0){
            return
          };
          this.comments = res.body.message
        })
      },
      getMessage:function(){
        var url = common.apiDomain + '/api/getcomments/' + this.artid + '?pageindex=1';
        this.$http.get(url).then(res=>{
          if(res.body.status !== 0){
            return
          };
          this.comments = res.body.message;
        })
      }

    }
  }
},


</script>

<style type="text/css" scoped>

</style>